//
//  WDDFlipView.m
//  SZBank
//
//  Created by rimi on 16/7/13.
//  Copyright © 2016年 LuoYao. All rights reserved.
//

#import "WDDFlipView.h"

@implementation WDDFlipView
{
    CGFloat frameWidth;/**  自身宽度 */
    CGFloat frameHeight;/**  自身高度 */
}

- (instancetype)initWithFrame:(CGRect)frame
{
    
    self = [super initWithFrame:frame];
    if (self) {

        frameWidth = self.frame.size.width;
        frameHeight = self.frame.size.height;
        
        UIButton *backButton = [[UIButton alloc] initWithFrame:CGRectMake(frameWidth * 0.89, frameHeight * 0.11, 60, 60)];
        [backButton setImage:[LocalDataManager getImageWithSourceOfPath:@"金融资讯_详情关闭"] forState:UIControlStateNormal];
        [backButton addTarget:self action:@selector(action_backButton) forControlEvents:UIControlEventTouchUpInside];
        
        [self addSubview:self.flipImageView];
        [self addSubview:backButton];
        [self addSubview:self.titleLabel];
        
        
    }
    return self;
}

- (void)action_backButton{
    
    [self removeFromSuperview];
}

- (UIImageView *)flipImageView{
    if (!_flipImageView) {
        _flipImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, frameWidth, frameHeight * 0.99)];
        _flipImageView.image = [LocalDataManager getImageWithSourceOfPath:@"金融资讯详情"];
    }
    return _flipImageView;
}

- (UILabel *)titleLabel{
    if (!_titleLabel) {
        _titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(frameWidth * 0.23, frameHeight * 0.11, frameWidth * 0.5, 60)];
        _titleLabel.backgroundColor = [UIColor clearColor];
        _titleLabel.textAlignment = NSTextAlignmentCenter;
        _titleLabel.font = [UIFont systemFontOfSize:35];
    }
    return _titleLabel;
}

- (UIImageView *)contentImage{
    if (!_contentImage) {
        _contentImage = [[UIImageView alloc] initWithFrame:CGRectMake(frameWidth * 0.07, frameHeight * 0.2, frameWidth * 0.86, frameHeight * 0.78)];
        _contentImage.backgroundColor = [UIColor clearColor];
         _contentImage.contentMode = UIViewContentModeScaleAspectFit;
    }
    return _contentImage;
}

- (UIWebView *)webView{
    if (!_webView) {
        _webView = [[UIWebView alloc] initWithFrame:CGRectMake(frameWidth * 0.08, frameHeight * 0.2, frameWidth * 0.84, frameHeight * 0.78)];
        _webView.dataDetectorTypes = UIDataDetectorTypeAll;
        _webView.backgroundColor = [UIColor clearColor];
        [_webView setOpaque:NO];
    }
    return _webView;
}
@end
